<?php
namespace App\Api\Controllers;
use Common\ApiController;
use Common\Models\H5page;
use Common\Models\Notices;
use Common\Models\NoticesUsed;

class H5pageController extends ApiController
{
    public function initialize()
    {
        parent::initialize();
    }

    /**
     * 单页详情
     */
    public function h5pageAction(){
        if(!isset($this->params['type']) && empty($this->params['type'])){
            $this->fail(-1,'类型不能为空');
        }
        $h5page = new H5page();
        $info = $h5page->findFirstByType($this->params['type']);
        $this->view->info = $info;
        $this->view->setVars(
            [
                "info" => $info,
            ]
        );
    }

    /**
     * 公告详情页面
     */
    public function noticedetailAction(){
        $params = array_merge($this->request->get(),$this->request->getPost());
        if(!isset($params['id']) || empty($params['id'])){
            echo "公告错误，没有找到id";die();
        }
        $noticesused = new NoticesUsed();
        $noticesused->is_read_used($params['user_id'],$params['id']);

        $notices = new Notices();
        $info = $notices->get_by_id($params['id']);
        $this->view->info = $info;
        $this->view->setVars(
            [
                "info" => $info,
            ]
        );
    }

    /**
     * 授权回调通知页面
     */
    public function relationtaobaoAction(){
        $params = array_merge($this->request->get(),$this->request->getPost());
        $this->view->info = $params;
        $this->view->setVars(
            [
                "info" => $params,
            ]
        );
    }


}
